<?php defined('SYSPATH') OR die('No direct access allowed.');

	print form::open(NULL,array('method'=>'get'));
	print form::open_fieldset();

	print form::legend('Wybierz kierunek i semestr, który chcesz obejrzeć:');
	
	print '<p>';
	$kierunek = array('informatyka'=>'Informatyka');
	print form::label('select-kierunek','<strong>Kierunek</strong>');
	print form::dropdown('select-kierunek',$kierunek,'informatyka');
	print '</p>';

	print '<p>';
	$studia = array('stacjonarne-inz'=>'I stopnia, stacjonarne');
	print form::label('select-studia','<strong>Studia</strong>');
	print form::dropdown('select-studia',$studia,'standard');
	print '</p>';

	print '<p class="buttons">';
	print form::submit(array('type'=>'submit','class'=>'button impotrant'),'Pokaż');
	print '</p>';

	print form::close_fieldset();
	print form::close();

	if($_GET) 
	{ 
		$tab = $this->input->get();

		$db = new Database;

		$table = 'courses';

		if ($db->table_exists($table))
		{
			for($i=1;$i<=7;$i+=1)
			{
							
				echo '<hr/>';
				echo '<p><center><h3><strong>Semestr '.((string)$i).'</strong></h3></center></p>';
				echo '<hr/>';
				$query = $db->select('DISTINCT courses.*')->from($table)->where('Sem='.$i)->get();
       	foreach ($query as $item)
				{
						echo '<p><strong>'.$item->Name.'</strong><br />';
						echo '<table width="100%"><tr width="100%"><td width="33%">'.$item->Code.'</td><td width="33%">ECTS:'.$item->ECTS.'</td><td width="33%">'.(($item->Pass == 1)?'Egzamin':'Zaliczenie').'</td><tr></table><br/>';
				}
			}
		}
		else
		{
			echo 'NO! The '.$table.' table doesn\'t exist, so we can\'t continue =( ';
		}
	}
	echo "<br/><br/>\n";
	echo 'done in {execution_time} seconds';    
	
?>

